#include "widget.h"
#include "ui_widget.h"
#include <QRect>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    mybutton = new QPushButton(this);
    mybutton-> setText("我是一条蛇");
    rect = mybutton->geometry();
}


Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    //rect.setY(rect.y() + 5);
    //mybutton->setGeometry(rect);
    rect = QRect(rect.x(),rect.y() - 5,rect.width(),rect.height());
    mybutton->setGeometry(rect);
    qDebug() << rect;
}

void Widget::on_pushButton_2_clicked()
{
//    rect.setX(rect.x() - 5);
//    mybutton->setGeometry(rect);

    rect = QRect(rect.x() - 5,rect.y(),rect.width(),rect.height());
    mybutton->setGeometry(rect);
    qDebug() << rect;
}

void Widget::on_pushButton_3_clicked()
{
//    rect.setX(rect.x() + 5);
//    mybutton->setGeometry(rect);
    rect = QRect(rect.x() + 5,rect.y(),rect.width(),rect.height());
    mybutton->setGeometry(rect);

    qDebug() << rect;
}

void Widget::on_pushButton_4_clicked()
{
//    rect.setY(rect.y() - 5);
//    mybutton->setGeometry(rect);
    rect = QRect(rect.x(),rect.y() + 5,rect.width(),rect.height());
    mybutton->setGeometry(rect);
    qDebug() << rect;
}


